// Copyright (c) 2023 FlyByWire Simulations
// SPDX-License-Identifier: GPL-3.0

#ifndef FLYBYWIRE_UNITS_H
#define FLYBYWIRE_UNITS_H

#include <string>

#include <MSFS/Legacy/gauges.h>

#include "logging.h"

/**
 * @brief The SimUnit struct is a helper struct representing one unit
 */
struct SimUnit {
 public:
  const char* name;
  const ENUM  id;
  [[maybe_unused]] explicit SimUnit(const char* nameInSim) : name(nameInSim), id(get_units_enum(name)) {
    // LOG_INFO("SimUnit::SimUnit() " + std::string(name) + " = " + std::to_string(id));
  }
};

/**
 * @brief The SimUnits class is a helper class to make handling of MSFS SDK units easier.
 */
class SimUnits {
 public:
  // Selected commonly used units

  const SimUnit None{""};  // special case for no unit (e.g., in conjunction with a data type)
  const SimUnit Bool{"Bool"};
  const SimUnit Celsius{"Celsius"};
  const SimUnit Feet{"Feet"};
  const SimUnit FeetMin{"feet/minute"};
  const SimUnit FeetSec{"feet/second"};
  const SimUnit FeetSecSquared{"feet per second squared"};
  const SimUnit FootPounds{"Foot pounds"};
  const SimUnit Gallons{"Gallons"};
  const SimUnit Gph{"Gallons per hour"};
  const SimUnit Hours{"Hours"};
  const SimUnit Mach{"Mach"};
  const SimUnit Millibars{"Millibars"};
  const SimUnit Minutes{"Minutes"};
  const SimUnit Number{"Number"};
  const SimUnit Percent{"Percent"};
  const SimUnit PercentOver100{"Percent over 100"};
  const SimUnit Pounds{"Pounds"};
  const SimUnit Pph{"Pounds per hour"};
  const SimUnit Psi{"Psi"};
  const SimUnit Rad{"radians"};
  const SimUnit RadSec{"radians per second"};
  const SimUnit RadSecSquared{"radians per second squared"};
  const SimUnit Seconds{"Seconds"};

  // All units taken from the MSFS SDK Examples SimWatcher
  const SimUnit Bco16{"Bco16"};
  const SimUnit Bool_{"Bool"};
  const SimUnit Boolean{"Boolean"};
  const SimUnit Enum{"Enum"};
  const SimUnit Frequency_ADF_BCD32{"Frequency ADF BCD32"};
  const SimUnit Frequency_BCD16{"Frequency BCD16"};
  const SimUnit Frequency_BCD32{"Frequency BCD32"};
  const SimUnit GForce{"GForce"};
  const SimUnit GLOBALP_delta_heading_rate{"GLOBALP->delta_heading_rate"};
  const SimUnit GLOBALP_eng1_manifold_pressure{"GLOBALP->eng1.manifold_pressure"};
  const SimUnit GLOBALP_eng1_oil_prs{"GLOBALP->eng1.oil_prs"};
  const SimUnit GLOBALP_eng1_oil_tmp{"GLOBALP->eng1.oil_tmp"};
  const SimUnit GLOBALP_vertical_speed{"GLOBALP->vertical_speed"};
  const SimUnit G_Force_624_scaled{"G Force 624 scaled"};
  const SimUnit G_Force{"G Force"};
  const SimUnit Hertz{"Hertz"};
  const SimUnit Hz{"Hz"};
  const SimUnit KHz{"KHz"};
  const SimUnit KgFSqCm{"KgFSqCm"};
  const SimUnit Kilohertz{"Kilohertz"};
  const SimUnit MHz{"MHz"};
  const SimUnit Megahertz{"Megahertz"};
  const SimUnit Nm{"Nm"};
  const SimUnit Pa{"Pa"};
  const SimUnit Slug_ft3{"Slug/ft3"};
  const SimUnit Slug_per_cubic_feet{"Slug per cubic feet"};
  const SimUnit Slug_per_cubic_foot{"Slug per cubic foot"};
  const SimUnit Slugs_per_cubic_feet{"Slugs per cubic feet"};
  const SimUnit Slugs_per_cubic_foot{"Slugs per cubic foot"};
  const SimUnit Watts{"Watts"};
  const SimUnit Watt{"Watt"};
  const SimUnit amperes{"amperes"};
  const SimUnit ampere{"ampere"};
  const SimUnit amps{"amps"};
  const SimUnit amp{"amp"};
  const SimUnit angl16{"angl16"};
  const SimUnit angl32{"angl32"};
  const SimUnit atmospheres{"atmospheres"};
  const SimUnit atmosphere{"atmosphere"};
  const SimUnit atm{"atm"};
  const SimUnit bars{"bars"};
  const SimUnit bar{"bar"};
  const SimUnit bels{"bels"};
  const SimUnit bel{"bel"};
  const SimUnit boost_cmHg{"boost cmHg"};
  const SimUnit boost_inHg{"boost inHg"};
  const SimUnit boost_psi{"boost psi"};
  const SimUnit celsius_fs7_egt{"celsius fs7 egt"};
  const SimUnit celsius_fs7_oil_temp{"celsius fs7 oil temp"};
  const SimUnit celsius_scaler_16k{"celsius scaler 16k"};
  const SimUnit celsius_scaler_1_256{"celsius scaler 1/256"};
  const SimUnit celsius_scaler_256{"celsius scaler 256"};
  const SimUnit celsius{"celsius"};
  const SimUnit centimeter_of_mercury{"centimeter of mercury"};
  const SimUnit centimeters_of_mercury{"centimeters of mercury"};
  const SimUnit centimeters{"centimeters"};
  const SimUnit centimeter{"centimeter"};
  const SimUnit cm2{"cm2"};
  const SimUnit cm3{"cm3"};
  const SimUnit cmHg{"cmHg"};
  const SimUnit cm{"cm"};
  const SimUnit cu_cm{"cu cm"};
  const SimUnit cu_ft{"cu ft"};
  const SimUnit cu_in{"cu in"};
  const SimUnit cu_km{"cu km"};
  const SimUnit cu_mm{"cu mm"};
  const SimUnit cu_m{"cu m"};
  const SimUnit cu_yd{"cu yd"};
  const SimUnit cubic_centimeters{"cubic centimeters"};
  const SimUnit cubic_centimeter{"cubic centimeter"};
  const SimUnit cubic_feet{"cubic feet"};
  const SimUnit cubic_foot{"cubic foot"};
  const SimUnit cubic_inches{"cubic inches"};
  const SimUnit cubic_inch{"cubic inch"};
  const SimUnit cubic_kilometers{"cubic kilometers"};
  const SimUnit cubic_kilometer{"cubic kilometer"};
  const SimUnit cubic_meters{"cubic meters"};
  const SimUnit cubic_meter{"cubic meter"};
  const SimUnit cubic_miles{"cubic miles"};
  const SimUnit cubic_mile{"cubic mile"};
  const SimUnit cubic_millimeters{"cubic millimeters"};
  const SimUnit cubic_millimeter{"cubic millimeter"};
  const SimUnit cubic_yards{"cubic yards"};
  const SimUnit cubic_yard{"cubic yard"};
  const SimUnit days{"days"};
  const SimUnit day{"day"};
  const SimUnit decibels{"decibels"};
  const SimUnit decibel{"decibel"};
  const SimUnit decimiles{"decimiles"};
  const SimUnit decimile{"decimile"};
  const SimUnit decinmiles{"decinmiles"};
  const SimUnit decinmile{"decinmile"};
  const SimUnit degree_angl16{"degree angl16"};
  const SimUnit degree_angl32{"degree angl32"};
  const SimUnit degree_latitude{"degree latitude"};
  const SimUnit degree_longitude{"degree longitude"};
  const SimUnit degree_per_second_ang16{"degree per second ang16"};
  const SimUnit degree_per_second_squared{"degree per second squared"};
  const SimUnit degree_per_second{"degree per second"};
  const SimUnit degrees_angl16{"degrees angl16"};
  const SimUnit degrees_angl32{"degrees angl32"};
  const SimUnit degrees_latitude{"degrees latitude"};
  const SimUnit degrees_longitude{"degrees longitude"};
  const SimUnit degrees_per_second_ang16{"degrees per second ang16"};
  const SimUnit degrees_per_second_squared{"degrees per second squared"};
  const SimUnit degrees_per_second{"degrees per second"};
  const SimUnit degrees{"degrees"};
  const SimUnit degree{"degree"};
  const SimUnit fahrenheit{"fahrenheit"};
  const SimUnit farenheit{"farenheit"};
  const SimUnit feet_minute{"feet/minute"};
  const SimUnit feet_per_minute{"feet per minute"};
  const SimUnit feet_per_second_squared{"feet per second squared"};
  const SimUnit feet_per_second{"feet per second"};
  const SimUnit feet_second{"feet/second"};
  const SimUnit feet{"feet"};
  const SimUnit flags{"flags"};
  const SimUnit foot_per_second_squared{"foot per second squared"};
  const SimUnit foot_pound_{"foot-pound"};
  const SimUnit foot_pounds_{"foot pounds"};
  const SimUnit foot_pounds{"foot-pounds"};
  const SimUnit foot_pound{"foot pound"};
  const SimUnit foot{"foot"};
  const SimUnit fs7_charging_amps{"fs7 charging amps"};
  const SimUnit fs7_oil_quantity{"fs7 oil quantity"};
  const SimUnit ft2{"ft2"};
  const SimUnit ft3{"ft3"};
  const SimUnit ft_lb_per_second{"ft lb per second"};
  const SimUnit ft_lbs{"ft-lbs"};
  const SimUnit ft_min{"ft/min"};
  const SimUnit ft{"ft"};
  const SimUnit gallon_per_hour{"gallon per hour"};
  const SimUnit gallons_per_hour{"gallons per hour"};
  const SimUnit gallons{"gallons"};
  const SimUnit gallon{"gallon"};
  const SimUnit geepounds{"geepounds"};
  const SimUnit geepound{"geepound"};
  const SimUnit gph{"gph"};
  const SimUnit grads{"grads"};
  const SimUnit grad{"grad"};
  const SimUnit halfs{"halfs"};
  const SimUnit half{"half"};
  const SimUnit hectopascals{"hectopascals"};
  const SimUnit hectopascal{"hectopascal"};
  const SimUnit hour_over_10{"hour over 10"};
  const SimUnit hours_over_10{"hours over 10"};
  const SimUnit hours{"hours"};
  const SimUnit hour{"hour"};
  const SimUnit in2{"in2"};
  const SimUnit in3{"in3"};
  const SimUnit inHg_64_over_64k{"inHg 64 over 64k"};
  const SimUnit inHg{"inHg"};
  const SimUnit inch_of_mercury{"inch of mercury"};
  const SimUnit inches_of_mercury{"inches of mercury"};
  const SimUnit inches{"inches"};
  const SimUnit inch{"inch"};
  const SimUnit in{"in"};
  const SimUnit kPa{"kPa"};
  const SimUnit kelvin{"kelvin"};
  const SimUnit keyframes{"keyframes"};
  const SimUnit keyframe{"keyframe"};
  const SimUnit kgf_meters{"kgf meters"};
  const SimUnit kgf_meter{"kgf meter"};
  const SimUnit kg{"kg"};
  const SimUnit kilogram_force_per_square_centime{"kilogram force per square centimeter"};
  const SimUnit kilogram_meter_squared{"kilogram meter squared"};
  const SimUnit kilogram_meters{"kilogram meters"};
  const SimUnit kilogram_meter{"kilogram meter"};
  const SimUnit kilogram_per_cubic_meter{"kilogram per cubic meter"};
  const SimUnit kilogram_per_second{"kilogram per second"};
  const SimUnit kilograms_meter_squared{"kilograms meter squared"};
  const SimUnit kilograms_per_cubic_meter{"kilograms per cubic meter"};
  const SimUnit kilograms_per_second{"kilograms per second"};
  const SimUnit kilograms{"kilograms"};
  const SimUnit kilogram{"kilogram"};
  const SimUnit kilometer_hour{"kilometer/hour"};
  const SimUnit kilometer_per_hour{"kilometer per hour"};
  const SimUnit kilometers_hour{"kilometers/hour"};
  const SimUnit kilometers_per_hour{"kilometers per hour"};
  const SimUnit kilometers{"kilometers"};
  const SimUnit kilometer{"kilometer"};
  const SimUnit kilopascal{"kilopascal"};
  const SimUnit km2{"km2"};
  const SimUnit km3{"km3"};
  const SimUnit km{"km"};
  const SimUnit knot_scaler_128{"knot scaler 128"};
  const SimUnit knots_scaler_128{"knots scaler 128"};
  const SimUnit knots{"knots"};
  const SimUnit knot{"knot"};
  const SimUnit kph{"kph"};
  const SimUnit lbf_feet{"lbf-feet"};
  const SimUnit lbs{"lbs"};
  const SimUnit liter_per_hour{"liter per hour"};
  const SimUnit liters_per_hour{"liters per hour"};
  const SimUnit liters{"liters"};
  const SimUnit liter{"liter"};
  const SimUnit m2{"m2"};
  const SimUnit m3{"m3"};
  const SimUnit m_s{"m/s"};
  const SimUnit mach_3d2_over_64k{"mach 3d2 over 64k"};
  const SimUnit machs{"machs"};
  const SimUnit mach{"mach"};
  const SimUnit mask{"mask"};
  const SimUnit mbars{"mbars"};
  const SimUnit mbar{"mbar"};
  const SimUnit meter_cubed_per_second{"meter cubed per second"};
  const SimUnit meter_cubed{"meter cubed"};
  const SimUnit meter_latitude{"meter latitude"};
  const SimUnit meter_per_minute{"meter per minute"};
  const SimUnit meter_per_second_scaler_256{"meter per second scaler 256"};
  const SimUnit meter_per_second_squared{"meter per second squared"};
  const SimUnit meter_per_second{"meter per second"};
  const SimUnit meter_scaler_256{"meter scaler 256"};
  const SimUnit meter_second{"meter/second"};
  const SimUnit meters_cubed_per_second{"meters cubed per second"};
  const SimUnit meters_cubed{"meters cubed"};
  const SimUnit meters_latitude{"meters latitude"};
  const SimUnit meters_per_minute{"meters per minute"};
  const SimUnit meters_per_second_scaler_256{"meters per second scaler 256"};
  const SimUnit meters_per_second_squared{"meters per second squared"};
  const SimUnit meters_per_second{"meters per second"};
  const SimUnit meters_scaler_256{"meters scaler 256"};
  const SimUnit meters_second{"meters/second"};
  const SimUnit meters{"meters"};
  const SimUnit meter{"meter"};
  const SimUnit mile_per_hour{"mile per hour"};
  const SimUnit miles_per_hour{"miles per hour"};
  const SimUnit miles{"miles"};
  const SimUnit mile{"mile"};
  const SimUnit millibar_scaler_16{"millibar scaler 16"};
  const SimUnit millibars_scaler_16{"millibars scaler 16"};
  const SimUnit millibars{"millibars"};
  const SimUnit millibar{"millibar"};
  const SimUnit millimeter_of_mercury{"millimeter of mercury"};
  const SimUnit millimeter_of_water{"millimeter of water"};
  const SimUnit millimeters_of_mercury{"millimeters of mercury"};
  const SimUnit millimeters_of_water{"millimeters of water"};
  const SimUnit millimeters{"millimeters"};
  const SimUnit millimeter{"millimeter"};
  const SimUnit minute_per_round{"minute per round"};
  const SimUnit minutes_per_round{"minutes per round"};
  const SimUnit minutes{"minutes"};
  const SimUnit minute{"minute"};
  const SimUnit mm2{"mm2"};
  const SimUnit mm3{"mm3"};
  const SimUnit mmHg{"mmHg"};
  const SimUnit more_than_a_half{"more_than_a_half"};
  const SimUnit mph{"mph"};
  const SimUnit m{"m"};
  const SimUnit nautical_miles{"nautical miles"};
  const SimUnit nautical_mile{"nautical mile"};
  const SimUnit newton_meters{"newton meters"};
  const SimUnit newton_meter{"newton meter"};
  const SimUnit newton_per_square_meter{"newton per square meter"};
  const SimUnit newtons_per_square_meter{"newtons per square meter"};
  const SimUnit nice_minute_per_round{"nice minute per round"};
  const SimUnit nice_minutes_per_round{"nice minutes per round"};
  const SimUnit nmiles{"nmiles"};
  const SimUnit nmile{"nmile"};
  const SimUnit numbers_{"numbers"};
  const SimUnit number{"number"};
  const SimUnit part{"part"};
  const SimUnit pascals{"pascals"};
  const SimUnit pascal{"pascal"};
  const SimUnit per_degree{"per degree"};
  const SimUnit per_hour{"per hour"};
  const SimUnit per_minute{"per minute"};
  const SimUnit per_radian{"per radian"};
  const SimUnit per_second{"per second"};
  const SimUnit percent_over_100{"percent over 100"};
  const SimUnit percent_scaler_16k{"percent scaler 16k"};
  const SimUnit percent_scaler_2pow23{"percent scaler 2pow23"};
  const SimUnit percent_scaler_32k{"percent scaler 32k"};
  const SimUnit percentage{"percentage"};
  const SimUnit percent{"percent"};
  const SimUnit position_128{"position 128"};
  const SimUnit position_16k{"position 16k"};
  const SimUnit position_32k{"position 32k"};
  const SimUnit position{"position"};
  const SimUnit pound_force_per_square_foot{"pound-force per square foot"};
  const SimUnit pound_force_per_square_inch{"pound-force per square inch"};
  const SimUnit pound_per_hour{"pound per hour"};
  const SimUnit pound_scaler_256{"pound scaler 256"};
  const SimUnit poundal_feet{"poundal feet"};
  const SimUnit pounds_per_hour{"pounds per hour"};
  const SimUnit pounds_scaler_256{"pounds scaler 256"};
  const SimUnit pounds{"pounds"};
  const SimUnit pound{"pound"};
  const SimUnit pph{"pph"};
  const SimUnit psf_scaler_16k{"psf scaler 16k"};
  const SimUnit psf{"psf"};
  const SimUnit psi_4_over_16k{"psi 4 over 16k"};
  const SimUnit psi_fs7_oil_pressure{"psi fs7 oil pressure"};
  const SimUnit psi_scaler_16k{"psi scaler 16k"};
  const SimUnit psi{"psi"};
  const SimUnit quarts{"quarts"};
  const SimUnit quart{"quart"};
  const SimUnit radian_per_second_squared{"radian per second squared"};
  const SimUnit radian_per_second{"radian per second"};
  const SimUnit radians_per_second_squared{"radians per second squared"};
  const SimUnit radians_per_second{"radians per second"};
  const SimUnit radians{"radians"};
  const SimUnit radian{"radian"};
  const SimUnit rankine{"rankine"};
  const SimUnit ratio{"ratio"};
  const SimUnit revolution_per_minute{"revolution per minute"};
  const SimUnit revolutions_per_minute{"revolutions per minute"};
  const SimUnit rounds{"rounds"};
  const SimUnit round{"round"};
  const SimUnit rpm_1_over_16k{"rpm 1 over 16k"};
  const SimUnit rpms{"rpms"};
  const SimUnit rpm{"rpm"};
  const SimUnit scaler{"scaler"};
  const SimUnit seconds{"seconds"};
  const SimUnit second{"second"};
  const SimUnit slug_feet_squared{"slug feet squared"};
  const SimUnit slugs_feet_squared{"slugs feet squared"};
  const SimUnit slugs{"slugs"};
  const SimUnit slug{"slug"};
  const SimUnit sq_cm{"sq cm"};
  const SimUnit sq_ft{"sq ft"};
  const SimUnit sq_in{"sq in"};
  const SimUnit sq_km{"sq km"};
  const SimUnit sq_mm{"sq mm"};
  const SimUnit sq_m{"sq m"};
  const SimUnit sq_yd{"sq yd"};
  const SimUnit square_centimeters{"square centimeters"};
  const SimUnit square_centimeter{"square centimeter"};
  const SimUnit square_feet{"square feet"};
  const SimUnit square_foot{"square foot"};
  const SimUnit square_inches{"square inches"};
  const SimUnit square_inch{"square inch"};
  const SimUnit square_kilometers{"square kilometers"};
  const SimUnit square_kilometer{"square kilometer"};
  const SimUnit square_meters{"square meters"};
  const SimUnit square_meter{"square meter"};
  const SimUnit square_miles{"square miles"};
  const SimUnit square_mile{"square mile"};
  const SimUnit square_millimeters{"square millimeters"};
  const SimUnit square_millimeter{"square millimeter"};
  const SimUnit square_yards{"square yards"};
  const SimUnit square_yard{"square yard"};
  const SimUnit thirds{"thirds"};
  const SimUnit third{"third"};
  const SimUnit times{"times"};
  const SimUnit volts{"volts"};
  const SimUnit volt{"volt"};
  const SimUnit yards{"yards"};
  const SimUnit yard{"yard"};
  const SimUnit yd2{"yd2"};
  const SimUnit yd3{"yd3"};
  const SimUnit years{"years"};
  const SimUnit year{"year"};
};

// Global instance of the SimUnits class
inline SimUnits UNITS{};

#endif  // FLYBYWIRE_UNITS_H
